<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../../views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新增停诊</title>
<head>
    <meta charset="utf-8">
    <title>新增停诊</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="/fdoctor-ms/statics/beginnerAdmin/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/fdoctor-ms/statics/beginnerAdmin/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/fdoctor-ms/statics/beginnerAdmin/css/btable.css" />
    
    <script type="text/javascript" src="/fdoctor-ms/statics/beginnerAdmin/plugins/layui/layui.js"></script>
    <script type="text/javascript" src="/fdoctor-ms/statics/js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="/fdoctor-ms/statics/js/inputTools.js"></script>
    
</head>

<body>
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 5px;margin-left: 5px;margin-right: 5px">
	  <legend>新增停诊
	  </legend>
	</fieldset>
	<form class="layui-form" action="" id="dataForm">
	<input type=hidden name="updateMan" id="updateMan" value="${sessionScope.user_in_session.userName}"/>
		<div class="layui-form-item" style="width: 90%">
			<div class="layui-inline" style="width: 90%;" >
				    <label class="layui-form-label">医院：</label>
				    <div class="layui-input-inline" ">
				    	<select name="orgId" id="orgId" lay-search style="width: 50%;">
							<option value="">可输入医院名搜索</option>
							<c:forEach items="${hospitalList}" var="hospitalItem">
								<option value="${hospitalItem.id}" <c:if test="${hospitalItem.id eq stopEntity.orgId}">selected</c:if>>${hospitalItem.orgName}</option>
							</c:forEach>
						</select>  
				    </div>
			</div>
		</div>
		<div class="layui-form-item" style="width: 90%">
			<label class="layui-form-label">停诊日期：</label>
				<div class="layui-inline" style="width: 32%;">
			    <div class="layui-input-inline">
			      <input type="date" name="startTime"  class="layui-input"  id="startTime" value="${today}">     
			    </div>
			    </div>
			    <a>至&nbsp;&nbsp;&nbsp;</a>
			    <div class="layui-inline" style="width: 32%;">
			    <div class="layui-input-inline">
			       <input type="date" name="endTime"  class="layui-input"  id="endTime" value="${today}">   
			    </div>
			    </div>
		</div>
		
		<div class="layui-form-item" style="width: 50%">
			<label class="layui-form-label" > 停诊时间段：</label>
			<div class="layui-input-block">
				<select name="packType"  lay-verify="" id="stopTime">
					<option value="1" >上午</option>
					<option value="2">下午</option>
					<option value="3"  selected="true">全天</option>
				</select> 
			</div>
		</div>  
		<div class="layui-form-item" style="width: 90%">
			<label class="layui-form-label" > 通知方式：</label>
			<div class="layui-input-block">
			      <input type="radio" name="notifyWay" value="0" title="推送消息">
			      <input type="radio" name="notifyWay" value="1" title="短信通知" checked>
			</div>
		</div>
		
		<div class="layui-form-item" style="width: 90%">
			<label class="layui-form-label">停诊原因：</label>
			<div class="layui-input-block">
		      <textarea rows="" cols="" name="stopReason" id="stopReason" class="layui-textarea"></textarea>
		    </div>
		</div>
		
		<hr>
	  <div align="center">
	  		<button class="layui-btn layui-btn-big layui-btn-primary layui-btn-radius" type="button" id="saveButton"><i class="layui-icon">&#xe618;</i>确认保存</button>
	  </div>
	</form>
	  
</body>

<script type="text/javascript">
	//初始化表单控件
layui.use(['jquery', 'form','laydate'], function() {
	$ = layui.jquery;
	form = layui.form();
	var laydate = layui.laydate;
	
    
    $('#saveButton').on('click',function(){
    	if($('#orgId').val() == ""){
    		layer.msg('请选择相应医院！',{icon: 7});
    		return;
    	}
    	if($('#stopReason').val() == null || $('#stopReason').val() == ''){
    		layer.msg('请输入停诊原因！',{icon: 7});
    		return;
    	}
    	
    	layer.confirm('确认保存？', {icon: 3, title:'提示'}, function(index){
			layer.close(index);
			$.ajax({
				type : 'POST',
				url : '/fdoctor-ms/outpatientStop/addStop',
				data : packParams(),
				success : function(data) {
					if (data.code == 200) {
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);
						parent.layer.msg('保存成功！', {
							icon : 1
						});
						parent.tableConfig();
					} else {
						parent.layer.msg('保存失败！', {
							icon : 2
						});
					}
				}
			});
		});
    });
    
    function packParams(){
    	
    	var notifyList=$("input[name='notifyWay']");
    	var notifyW="";
    	for(i=0;i<notifyList.length;i++){
    		if(notifyList[i].checked){
    			notifyW=notifyList[i].value;
    		}
    	}
    	var param = {
    			updateMan: $('#updateMan').val(), 
    			orgId: $('#orgId').val(),
    			startTime : $('#startTime').val(),
    			endTime : $('#endTime').val(),
    			stopTime : $('#stopTime').val(),
				notifyWay : notifyW,
				stopReason : document.getElementById('stopReason').value
		}
		return param;
	}
    
   
})
</script>
</html>